/*
	Copyright (C) 2008 Demiurg-HG
	
	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
// i_filesys.h - interface for virtual file system


#pragma once


enum	fileSeekMode_t
	{
		FS_SEEK_BEGIN,
		FS_SEEK_END,
		FS_SEEK_CURRENT,
	};
	
enum	fileOpenMode_t
	{
		FS_OPEN_READ,
		FS_OPEN_WRITE,
		FS_OPEN_APPEND,
	};


interface	IFile
	{
		virtual				~IFile	( void ) {};
		
		virtual const char		*Name	( void ) const = 0;
		virtual uint			Size	( void ) const = 0;
		virtual fileOpenMode_t	Mode	( void ) const = 0;
		
		virtual uint			Read	( void *buffer, uint size ) = 0;
		virtual uint			Write	( const void *buffer, uint size ) = 0;
		virtual uint			Seek	( int dist, fileSeekMode_t origin ) = 0;
		
		virtual void			Flush	( void ) = 0;
		virtual void			Printf	( const char *frmt, ... ) = 0;
	};
	
interface	IFSSearch
	{
		virtual				~IFSSearch		( void ) {};
		virtual	uint		GetItemNum		( void ) const = 0;
		virtual const char	*GetItemName	( uint n ) const = 0;
	};


interface	IFileSystem	
	{
		virtual					~IFileSystem	( void ) {}
		
		virtual void			UpdatePackInfo	( void ) = 0;

		virtual	void			MkDir		( const char *path ) = 0;
		virtual void			RmDir		( const char *path ) = 0;
		virtual void			ChDir		( const char *path ) = 0;
		virtual const char		*GetDir		( void ) = 0;

		virtual bool			FileExists	( const char *path ) = 0;
		virtual void			FileDelete	( const char *path ) = 0;
		virtual const char		*UniqueName	( const char *path, const char *part, const char *ext ) = 0;
		
		virtual IFile			*FileOpen	( const char *name, fileOpenMode_t mode ) = 0;
		virtual	void			FileClose	( IFile *file ) = 0;
		
		virtual	IFSSearch		*BeginSearch	( const char *dir, const char *mask, bool ignore_archives=false ) = 0;
		virtual void			EndSearch		( IFSSearch *fss ) = 0;
	};
	
	
	
	